package edu.lingnan.lingnanblog.controller.admin;

import edu.lingnan.lingnanblog.entity.BlogType;
import edu.lingnan.lingnanblog.entity.PageBean;
import edu.lingnan.lingnanblog.service.BlogService;
import edu.lingnan.lingnanblog.service.BlogTypeService;
import edu.lingnan.lingnanblog.utils.ResponseUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/blogType")
public class BlogTypeAdminController {

	@Resource
	private BlogTypeService blogTypeService;
	
	@Resource
	private BlogService blogService;

	@RequestMapping("/list")
	public List<BlogType> list(Map<String, Object> map){
		return blogTypeService.list(map);
	}
	@RequestMapping("/getTotal")
	public Long getTotal(Map<String, Object> map){
		return blogTypeService.getTotal(map);
	}

	@RequestMapping("/add")
	public Integer add(BlogType blogType){
			blogTypeService.update(blogType);
		return blogTypeService.add(blogType);
	}
	@RequestMapping("/update")
	public Integer update(BlogType blogType){

		return blogTypeService.update(blogType);
	}
	@RequestMapping("/getBlogByTypeId")
	public Integer getBlogByTypeId(@RequestParam(value="id") int id){
		return blogService.getBlogByTypeId(id);
	}

	@RequestMapping("/delete")
	public Integer delete(@RequestParam(value="id") int id){
		return blogTypeService.delete(id);
	}
	@RequestMapping("toEditBlogType")
	public String toEditBlogType(){
		return "admin/blogTypeManage";
	}

}
